import 'package:flutter/material.dart';

class MainDemo extends StatelessWidget {
  final keys = GlobalKey<ScaffoldState>();
  @override
  Widget build(BuildContext context) {
    List alltabs = [
      '首页',
      '交易',
      '订单',
      '转态',
      '帮助',
      '个人中心',
    ];
    return new DefaultTabController(
        length: alltabs.length,
        child: new Scaffold(
          key: keys,
          appBar: AppBar(
            leading: new IconButton(
              icon: new Icon(Icons.pages),
              onPressed: () {
                keys.currentState.openDrawer();
              },
            ),
            centerTitle: true,
            title: Container(
              child: new TabBar(
                isScrollable: true,
                labelPadding: EdgeInsets.all(12.0),
                indicatorSize: TabBarIndicatorSize.label,
                tabs: alltabs.map((item) {
                  return Tab(
                    text: '$item',
                  );
                }).toList(),
              ),
            ),
            actions: <Widget>[
              new IconButton(icon: new Icon(Icons.search), onPressed: () {})
            ],
          ),
          body: new TabBarView(
            children: alltabs.map((item) {
              return Text('$item');
            }).toList(),
          ),
          drawer: new Drawer(
            child: new Container(
              child: Center(
                child: Text('data'),
              ),
            ),
          ),
        ));
  }
}
